#pragma once

#include "Type.h"

class FloatType final : public Type {
public:
    /// @brief 获取全局唯一的 32 位浮点类型
    static Type * getTypeFloat();

    [[nodiscard]] std::string toString() const override
    {
        return "float";
    }

    [[nodiscard]] int32_t getBitWidth() const override
    {
        return bitWidth;
    }

    [[nodiscard]] bool isFloat32() const
    {
        return bitWidth == 64;
    }

    [[nodiscard]] int32_t getSize() const override
    {
        return bitWidth / 8;
    }

    /// @brief 是否为浮点类型
    bool isFloatType() const
    {
        return true;
    }

private:
    explicit FloatType(int32_t _bitWidth) : Type(Type::FloatTyID), bitWidth(_bitWidth)
    {}

    static FloatType * oneInstanceFloat;
    int32_t bitWidth;
};